package com.itwelkin.ssm.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Admin {
    private Integer id; //主键id
    private String username; //账号姓名
    private String password; //账号密码
    private String email;   //注册邮箱
    private Date regTime;   //注册时间
    private String activeCode;  //激活码
    private Integer activeStatus; //激活状态
    private Integer authorizeStatus; //授权状态
    private Integer loginFailCount; //登录失败次数
    private Date loginFailTime; //登陆失败时间
    private Date lastLoginTime; //最后一次登录时间
    private Integer isVisible; //是否可见

    @Override
    public String toString() {
        return "Admin{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", email='" + email + '\'' +
                ", regTime=" + regTime +
                ", activeCode='" + activeCode + '\'' +
                ", activeStatus=" + activeStatus +
                ", authorizeStatus=" + authorizeStatus +
                ", loginFailCount=" + loginFailCount +
                ", loginFailTime=" + loginFailTime +
                ", lastLoginTime=" + lastLoginTime +
                ", isVisible=" + isVisible +
                '}';
    }
    public long getCountdown(){
        long result = 30-(new Date().getTime() - getLoginFailTime().getTime())/1000/60;
        if (result>=0){
            return  result;

        }
        return -1;
    }
}
